define([
    'angular',
    'system/employee/EmployeeControllerConstructor',
    'framework/grid/GillionGridModule'
], function (angular, EmployeeControllerConstructor) {
    return angular.module('EmployeeModule', ['GillionGridModule'])
        .controller('EmployeeController', function ($scope, $http) {
            $scope.employee={
                name:'liaowj'
            };
            $scope.addRole = function () {
                if (!angular.isArray($scope.employee.roles)) {
                    $scope.employee.roles = [{}];
                } else {
                    $scope.employee.roles.push({});
                }
            } ;

            $scope.employeeGridColumns = [
                {header:'name', data:'name'},
                {header:'age', data:'age'},
                {header:'sex', data:'sex | sexToCn'},
                {header:'email', data:'email'},
                {header:'mobile', data:'mobile'},
                {header:'telephone', data:'telephone'}
            ];

            $scope.employeeGridInitCallback = function (grid) {
                console.log(grid.source)

            } ;

            $scope.testSubmit = function () {
                console.log($scope.UserForm);
                console.log($scope.employee);
                $http.post('/gillion-web/system/employees', {
                    password: '123456',
                    confirmPassword: '123456',
                    mobile: '18659297460',
                    dept: {
                        id: '1',
                        deptName: '制造部'
                    },
                    roles: [
                        {
                            id: '1',
                            roleName: '管理员'
                        }
                    ]
                }, function (result) {
                    console.log(result)
                })
            };

        });
});